// src/utils/auth.ts

// 定义用户信息接口（根据实际数据结构调整）
export interface UserInfo {
    [key: string]: unknown; // 或更具体的字段，例如：id: number; name: string;
}

// Token 操作
export const setToken = (token: string): void => localStorage.setItem('token', token);
export const getToken = (): string | null => localStorage.getItem('token');
export const clearToken = (): void => localStorage.removeItem('token');

// 用户信息操作
export const getUserInfo = (): UserInfo | null => {
    const data = localStorage.getItem('userInfo');
    return data ? (JSON.parse(data) as UserInfo) : null;
};

export const setUserInfo = (userInfo: UserInfo): void => {
    localStorage.setItem('userInfo', JSON.stringify(userInfo));
};
